package com.dayu.app;

import java.util.TimeZone;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.dayu.unitalk.ua.server.UnitalkUaServer;

/**
 * @ClassName: 最终运行类
 * @Description:TODO
 * @author: 戴卫国
 * @date: 2018年2月26日 下午2:35:22
 * 
 * @Copyright: 2018 dayu Inc. All rights reserved.
 */
@Component
public class App implements InitializingBean {

	static Logger LOGGER = LoggerFactory.getLogger(App.class);

	public static void main(String[] args) throws Exception {
		long zero = 1532258908 / (1000 * 3600 * 24) * (1000 * 3600 * 24) - TimeZone.getDefault().getRawOffset();
		LOGGER.info("启动OPC UA Server...");
		// com.dayu.web.Application.main();
	}

	@Value(value = "${opcua.server.enabled:false}")
	private boolean opcUaServerEnabled;

	@Override
	public void afterPropertiesSet() throws Exception {

		if (opcUaServerEnabled) {

			LOGGER.info("启动OPC UA Server...");
			new UnitalkUaServer().startup().get();
		}
	}
}
